<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // async返回的是一个Promise对象
    async function getData() {
        // throw new Error("出错了");// 抛出错误,promise对象为rejected
        return new Promise((resolve, reject) => {
            resolve("成功");
            // reject("失败");
        });
    }
    const result = getData();
    result.then(value => {
        console.log(value);
    }, reason => {
        console.log(reason);
    })
    console.log(result);
</script>

</html>